﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using GameEngine.SceneGraph;

//--Axe
namespace Redland2
{
    public class Axe : Gun
    {
        #region members
        #endregion members

        #region properties
        #endregion properties

        #region constructors

        public Axe(GameScene inputScene, int inputIndex, Player inputOwner, Vector2 position ): base( inputScene, inputIndex, inputOwner, position )
        {
            SetupMelee();
        }

        private void SetupMelee()
        {
            this.FireDelay = 250;
            this.Damage = 50;
        }

        #endregion constructors

        #region methods
        public override void Fire()
        {
            if (scene._time.Subtract(TimeSpan.FromMilliseconds(FireDelay)) > LastShot && this.IsAlive() && Owner.IsAlive())
            {
                LastShot = scene._time;
                Vector2 offsetPosition = this.Position;
                offsetPosition += Vector2.Transform(Direction, Matrix.CreateRotationZ(MathHelper.PiOver2)) * 4; // offset bullet to the right of center of player
                offsetPosition += Direction * this.TextureWidth; // offset bullet to tip of barrel
                Vector2 shotDirection = Owner.TargetPos - offsetPosition;
                shotDirection.Normalize();
                

                scene._entities.Add(new MeleeSwing(this.scene, this.scene._entities.Count, this.Owner, offsetPosition, shotDirection, Damage));
            }
            //base.Fire();
        }
        #endregion methods 
    }
}
